<html>
<!--
 -  
 -  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
 -  project.
 -  
 -  Copyright (C) 1998-2024 OpenLink Software
 -  
 -  This project is free software; you can redistribute it and/or modify it
 -  under the terms of the GNU General Public License as published by the
 -  Free Software Foundation; only version 2 of the License, dated June 1991.
 -  
 -  This program is distributed in the hope that it will be useful, but
 -  WITHOUT ANY WARRANTY; without even the implied warranty of
 -  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 -  General Public License for more details.
 -  
 -  You should have received a copy of the GNU General Public License along
 -  with this program; if not, write to the Free Software Foundation, Inc.,
 -  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 -  
 -  
-->
<HEAD>
       <script language="JavaScript" src="../ajax_inc/ajax.js"></script>
       <script language="JavaScript" src="../ajax_inc/proxy.vsp?wsdl_path=SOAP_SO_S_11/services.wsdl"></script>
       <link rel="stylesheet" type="text/css" href="../demo.css" />
<SCRIPT language="JavaScript">

var ch = 2;

var browsertype;
if (document.implementation.createDocument)
{ 
    browsertype='Mozila';
   // Mozilla, create a new DOMParser 
   var parser = new DOMParser();
   var xsltProcessor = new XSLTProcessor(); 


    // load the xslt file
    var myXMLHTTPRequest = new XMLHttpRequest();
    myXMLHTTPRequest.open("GET", "sr.xsl", false);
    myXMLHTTPRequest.send(null);
    
    // parse XSLT text to XML DOM(when not local responseXML is set null ???)
    xslDoc = parser.parseFromString(myXMLHTTPRequest.responseText, "text/xml");
    xsltProcessor.importStylesheet(xslDoc);

}
else if (window.ActiveXObject)
{ 
  browsertype='IE';
  var xslDoc = new ActiveXObject("Microsoft.XMLDOM");
  var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
  xslDoc.async = false;
  xmlDoc.async = false;
  xslDoc.load("sr.xsl");

}

function adiv ()
{
  ajax.Start(administrative_divisions,'');
}


function cResultsAjax(result)
{
      // Show the result
      document.getElementById('divMenuCountry').innerHTML = result;
}

function mResultsAjax(result)
{   try
    	{
             if(browsertype=='IE')
             {
               xmlDoc.loadXML (result);
               document.getElementById('divMenuToken').innerHTML = xmlDoc.transformNode(xslDoc.documentElement);
             }
             else
             {  
               xmlDoc = parser.parseFromString(result, "text/xml");

         			 var resultDocument = xsltProcessor.transformToFragment(xmlDoc, document);
       				 document.getElementById("divMenuToken").innerHTML='';
       				 document.getElementById("divMenuToken").appendChild(resultDocument);
             }   
 	    }
      catch (e)
	    {
	        alert('Parser exception:'+e.description);
	    }
}

function dWait(dowhat){
  if(dowhat=='show'){
    document.getElementById('divWait').style.visibility='visible';
  }else{
    document.getElementById('divWait').style.visibility='hidden';
  }
}
</SCRIPT>
</HEAD>
<body onLoad="ajax.Start(countries,'');ajax.Start(administrative_divisions,'');">
<H3>DHTML behaviours to Web Services</H3>
<form method="POST" name="divisions" action="administrative_divisions_ch.html">
<table class="tableentry">
<tr>
  <td>1. Select country</td>
  <td>
  <DIV ID="divMenuCountry"></DIV>
  <!--input type="text" name="country" size="15" value="United States"/><small>'%' wilcard</small-->
  </td>
</tr>
</table>
</form>
      <script defer="defer" type="text/javascript">
          var countries = {
            delay: 200,
            prepare: function() {return ch;},
            call: proxies.SOAP.countries,
            finish: function(p){cResultsAjax(p);},
            onException: proxies.alertException
          }

          var administrative_divisions = {
            delay: 200,
            prepare: function() {dWait('show');return Array(document.getElementById('country').value,'','');},
            call: proxies.SOAP.administrative_divisions,
            finish: function(p){dWait('hide');mResultsAjax(p);},
            onException: proxies.alertException
          }

      </script>

<DIV ID="divWait" style="visibility:hidden;"><font color="red">Please wait...</font></DIV>
<DIV ID="divMenuToken"></DIV>
</body>
</html>
